package com.heima.admin.service.impl;

import com.heima.admin.dao.WmSensitiveDao;
import com.heima.admin.service.AdSensitiveService;
import com.heima.model.common.admin.dto.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.common.wemedia.entity.WmSensitive;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AdSensitiveServiceImpl implements AdSensitiveService {

   @Resource
   private WmSensitiveDao wmSensitiveDao;
    @Override
    public ResponseResult save(AdSensitive dto) {
        if (dto==null || StringUtils.isBlank(dto.getSensitives())) {
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_REQUIRE);
        }
        WmSensitive wmSensitive = new WmSensitive();
        wmSensitive.setSensitives(dto.getSensitives());
        wmSensitive.setCreatedTime(dto.getCreatedTime());
        wmSensitive.setUpdatedTime(dto.getCreatedTime());

        wmSensitiveDao.insert(wmSensitive);
        return ResponseResult.okResult(wmSensitive);
    }
}
